﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Cryptography.cs" company="">
//   Copyright (c) 2010/2011 All Right Reserved
// </copyright>
// <summary>
//   Contains Cryptography class declaration.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace iBuproModel.Classes
{
    using System;
    using System.Security.Cryptography;
    using System.Text;
    
    
    /// <summary>
    /// Basic cryptography class for password salting
    /// </summary>
    public class Cryptography
    {
        public static string GetSHA256(string text)
        {
            byte[] data = new byte[text.Length];
            byte[] result;
            SHA256 shaM = new SHA256Managed();
            result = shaM.ComputeHash(data);

            return ASCIIEncoding.ASCII.GetString(result);
        }

        public static string GenerateSalt()
        {
            Random rand = new Random();
            return rand.Next(1000, 1000000).ToString();
        }
    }
}
